package com.wb.mianxiangduixiang.租车系统1;

import java.util.Scanner;

/**
 * @author 黄衡熙
 * @version 1.0
 * @date 2025年07月21日16:14
 */
public class Test {
    public static void main(String[] args) {
        // 1.进入租车系统,输入客户信息
        System.out.println("************************欢迎来到紫金租车店************************");
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入您的姓名:");
        String name = sc.next();
        System.out.print("请输入您的手机号:");
        String number = sc.next();
        // 客户对象
        Customer customer = new Customer();
        customer.setName(name);
        customer.setPhone(number);
        //创建一个机动车数组
        MotorVehicle[] cars = new MotorVehicle[100];
        int count = 0;

        // 2.选择需要租赁的汽车类型(轿车、客车、退出)以及具体的车型(根据选择的类型不同展示不同的车型)
        // 租车时可以租赁多辆汽车,通过死循环实现
        while (true) {
            System.out.print("请选择租赁的汽车类型(1.轿车 2.客车 3.退出):");
            int choice = sc.nextInt();
            if (choice == 1) {
                System.out.print("请选择轿车的车型(1.宝马X1 2.奔驰GLC 3.保时捷帕拉梅拉 4.劳斯莱斯幻影):");
                int x = sc.nextInt();
                Car car = new Car();
                switch (x) {
                    case 1:
                        car.setType(CarConstant.BMW_X1);
                        car.setBrand("宝马");
                        break;
                    case 2:
                        car.setType(CarConstant.BENZ_GLC);
                        car.setBrand("奔驰");
                        break;
                    case 3:
                        car.setType(CarConstant.PORSCHE_PANAMERA);
                        car.setBrand("保时捷");
                        break;
                    case 4:
                        car.setType(CarConstant.ROLLS_ROYCE_PHANTOM);
                        car.setBrand("劳斯莱斯");
                        break;
                    default:
                        System.out.println("无效选择!");
                        continue;
                }
                System.out.print("请输入车牌号:");
                String no = sc.next();
                car.setNo(no);
                cars[count++] = car;
            } else if (choice == 2) {
                System.out.print("请选择客车的车型(1.20座考斯特 2.25座奔驰凌特 3.35座宇通客车 4.45座金龙客车):");
                int y = sc.nextInt();
                Bus bus = new Bus();
                switch (y) {
                    case 1:
                        bus.setSeatCount(20);
                        bus.setBrand("考斯特");
                        break;
                    case 2:
                        bus.setSeatCount(25);
                        bus.setBrand("奔驰");
                        break;
                    case 3:
                        bus.setSeatCount(35);
                        bus.setBrand("宇通");
                        break;
                    case 4:
                        bus.setSeatCount(45);
                        bus.setBrand("金龙");
                        break;
                    default:
                        System.out.println("无效选择!");
                        continue;
                }
                System.out.print("请输入车牌号:");
                String no = sc.next();
                bus.setNo(no);
                cars[count++] = bus;
            } else if (choice == 3) {
                // 退出循环
                break;
            } else {
                System.out.println("输入无效");
            }
        }

        // 3.车辆选择完成之后指定租赁的天数
        System.out.print("请输入这些机动车租赁的天数:");
        int day = sc.nextInt();
        // 4.展示客户租赁的所有车辆的车牌与品牌信息
        // 车牌号          品牌
        // 苏A0001       宝马
        // xxx          xxx
        System.out.println("客户租赁车辆信息信息:");
        System.out.println("车牌号   品牌");
        for (int i = 0; i < count; i++) {
            MotorVehicle vehicle = cars[i];
            System.out.println(vehicle.getNo() + "  " + vehicle.getBrand());
        }
        // 5.打印共租赁了几辆机动车,租赁了多少天,总租金多少元
        System.out.println("客户姓名:" + name + "\n" + "客户手机号:" + number);
        double totalRent = 0;
        for (int i = 0; i < count; i++) {
            totalRent += cars[i].rent(day);
        }
        System.out.println("共租凭了:" + count + "辆车," + "租凭了:" + day + "天," + "总租金为:" + totalRent + "元");

    }
}
